<template>
  <div>
    <cell-group>
      <cell title="当周数据" label="使用上周五到当周周四的数据作为当周数据">
        <template #right-icon>
          <van-switch v-model="useLastWeekData" @change="setUseLastWeekData"></van-switch>
        </template>
      </cell>
      <cell title="快捷添加" label="通过数字键盘来输入上下班时间">
        <template #right-icon>
          <van-switch v-model="useQuickAdd" @change="setUseQuickAdd"></van-switch>
        </template>
      </cell>
    </cell-group>
  </div>
</template>

<script>
import { Cell, CellGroup, Switch  } from 'vant';
export default {
  name: "setting",
  components:{ Cell, CellGroup, 'van-switch': Switch },
  data(){
    return{
      useLastWeekData: false,
      useQuickAdd: false,
    }
  },
  methods:{
    initData(){
      this.useLastWeekData = localStorage.getItem("useLastWeekData") === '1'
      this.useQuickAdd = localStorage.getItem("useQuickAdd") !== '0'
    },
    setUseLastWeekData(){
      localStorage.setItem("useLastWeekData", this.useLastWeekData ? "1" : "0")
    },
    setUseQuickAdd(){
      localStorage.setItem("useQuickAdd", this.useQuickAdd ? "1" : "0")
    }
  },
  created() {
    this.initData()
  }
}
</script>

<style scoped>

</style>